Skip to content

[Pagination] Support Symfony UID cursor fields - #4111

Merged
Kocal merged 1 commit into
symfony:3.xfrom
norkunas:pagination-uid-cursor
Oct 19, 2026
Merged

Kocal merged 1 commit into
symfony:3.xfrom
norkunas:pagination-uid-cursor

Conversation

@norkunas

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? yes
Issues -
License MIT

Entities identified by a Symfony UID cannot be cursor-paginated with Doctrine ORM. The first page renders, but following the "next" link fails, because the identifier is always appended as the tie-breaker:

$paginator->cursor($queryBuilder)->orderBy(['createdAt'], 'DESC')->paginate();
// Doctrine type "uuid" of cursor field "id" is not supported.

Binding a UID as a query parameter fails too, before any page is rendered:

$queryBuilder->andWhere('o.owner = :owner')->setParameter('owner', $userId, UuidType::NAME);
// Cannot derive a stable cursor context from Doctrine parameter object "Symfony\Component\Uid\UuidV7".

With this PR:

  • Cursor values hold a UID's string form (RFC 4122 for UUIDs, base32 for ULIDs)
  • When a cursor is read, the value is converted back through the field's own Doctrine type (any AbstractUidType, so uuid, ulid and custom subclasses) and bound with that type. The database then compares UIDs in its storage format (binary on SQLite/MySQL, native uuid on PostgreSQL), which is also the order ORDER BY uses
  • UID query parameters are fingerprinted in the cursor context as their class and string form

symfony/doctrine-bridge and symfony/uid are only needed as dev dependencies: the adapter checks instanceof, so nothing changes for applications without them.

#4102 edits the same type allow-list and the same docs sentence for date columns, so whichever is merged second needs a small rebase.

🤖 Generated with Claude Code

@carsonbot carsonbot added Documentation Improvements or additions to documentation Feature New Feature Pagination Status: Needs Review Needs to be reviewed labels Oct 16, 2026
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Kocal
Kocal force-pushed the pagination-uid-cursor branch from 5ce3993 to bdfa461 Compare October 19, 2026 14:56
@Kocal

Kocal commented Oct 19, 2026

Copy link
Copy Markdown
Member

Thank you @norkunas.

@Kocal
Kocal merged commit fa23054 into symfony:3.x Oct 19, 2026
35 of 36 checks passed
@norkunas
norkunas deleted the pagination-uid-cursor branch October 19, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Feature New Feature Pagination Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants